<template>
  <div 
    class="group relative overflow-hidden rounded-lg bg-white dark:bg-secondary-700 shadow-card transition-all duration-300 cursor-pointer hover:shadow-card-hover hover:-translate-y-1"
    @click="handleClick"
  >
    <div class="relative aspect-square overflow-hidden">
      <img 
        :src="artwork.imageUrl" 
        :alt="artwork.title" 
        class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
      />
      
      <!-- 分类标签 -->
      <div class="absolute top-3 left-3">
        <span class="badge-secondary">{{ artwork.category }}</span>
      </div>
      
      <!-- 视频播放按钮 -->
      <div 
        v-if="artwork.isVideo" 
        class="absolute right-3 bottom-3 w-10 h-10 rounded-full bg-white/80 dark:bg-secondary-800/80 flex items-center justify-center text-primary-600 dark:text-primary-400"
      >
        <el-icon class="text-xl"><VideoPlay /></el-icon>
      </div>
      
      <!-- 新功能标签 -->
      <div 
        v-if="artwork.isNew" 
        class="absolute top-3 right-3 px-2 py-1 bg-danger-500 text-white text-xs font-medium rounded-md"
      >
        新功能
      </div>
      
      <!-- 企业版标签 -->
      <div 
        v-if="artwork.isEnterprise" 
        class="absolute bottom-3 left-3 px-2 py-1 bg-warning-500 text-secondary-900 text-xs font-medium rounded-md"
      >
        企业版
      </div>
      
      <!-- 悬停时显示的信息 -->
      <div class="absolute inset-0 bg-gradient-to-t from-secondary-900/70 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4">
        <h3 class="text-white font-medium text-lg mb-1">{{ artwork.title }}</h3>
        <p class="text-white/80 text-sm">点击查看详情</p>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, defineEmits } from 'vue';
import { VideoPlay } from '@element-plus/icons-vue';

interface Artwork {
  id: string;
  imageUrl: string;
  title: string;
  category: string;
  isVideo?: boolean;
  isNew?: boolean;
  isEnterprise?: boolean;
}

const props = defineProps<{
  artwork: Artwork;
}>();

const emit = defineEmits(['click']);

const handleClick = () => {
  emit('click', props.artwork);
};
</script>

<style lang="scss" scoped>
.artwork-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background-color: #fff;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
  margin-bottom: 16px;
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.1);
  }
}

.artwork-image-container {
  position: relative;
  width: 100%;
  padding-top: 100%; // Relación de aspecto 1:1
  overflow: hidden;
  
  &.portrait {
    padding-top: 133%; // Relación de aspecto 3:4
  }
  
  &.landscape {
    padding-top: 75%; // Relación de aspecto 4:3
  }
}

.artwork-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.play-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b5cc4;
  font-size: 20px;
  
  .el-icon {
    font-size: 20px;
  }
}

.new-feature-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: #ff6b6b;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.enterprise-tag {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background-color: #ffc107;
  color: #333;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}
</style> 